﻿<%@ Control Language="C#" AutoEventWireup="true" CodeFile="ListPlayer.ascx.cs" Inherits="SMS.Admin.Modules.ListPlayer" %>
<%@ Import Namespace="SMS.Helper" %>
<table cellpadding="0" cellspacing="0" border="0" width="100%">
    <tr>
        <td colspan="2" align="center"><h3 class="title">DANH SÁCH CẦU THỦ</h3></td>
    </tr>
    <tr>
        <td>Tên cầu thủ</td>
        <td><asp:TextBox ID="txtPlayerName" runat="server" Width="250px" />&nbsp;<asp:Button ID="btnSearch" runat="server" Text="Tìm" Width="60px" OnClick="btnSearch_Click" /></td>
    </tr>
    <tr>
        <td colspan="2" align="center"><asp:Label ID="lblError" runat="server" ForeColor="Red" /></td>
    </tr>
    <tr>
        <td colspan="2" align="left" class="links"><asp:Button ID="lnkAdd" runat="server" OnClick="lnkAdd_Click" Text="Thêm mới" />&nbsp;&nbsp;&nbsp;<asp:Button ID="lnkDelete" runat="server" OnClick="lnkDelete_Click" Text="Xóa" />&nbsp;&nbsp;<asp:Button ID="lnkApprove" runat="server" OnClick="lnkApprove_Click" Text="Phê duyệt" /></td>
    </tr>
    <tr>
        <td colspan="2" align="center">
        <asp:GridView ID="grvPlayer" runat="server" Width="98%" 
            AutoGenerateColumns="False" AllowPaging="True" PageSize="40" AllowSorting="True" 
            CellPadding="4" ForeColor="#333333" PagerStyle-HorizontalAlign="Center" 
            EmptyDataText="Không có bản ghi nào." PagerSettings-NextPageText="Next" 
            PagerSettings-PreviousPageText="Prev" PagerStyle-CssClass="pagerText" OnPageIndexChanging="grvPlayer_PageIndexChanging">
            <PagerSettings PageButtonCount="10" />
            <FooterStyle BackColor="#1EB5DD" Font-Bold="True" ForeColor="White" />
            <PagerStyle BackColor="#1EB5DD" ForeColor="White" />
            <RowStyle Height="30px" ForeColor="#333333" HorizontalAlign="Center" />
            <HeaderStyle BackColor="#eeecdf" Font-Bold="True" ForeColor="#a4363a" />
            <AlternatingRowStyle BackColor="#f7f6f0" Height="30px" ForeColor="#284775" />
            <Columns>
                <asp:TemplateField>
                    <HeaderStyle HorizontalAlign="Center" Width="40px" />
                    <HeaderTemplate>
                        <input type="checkbox" id="cbxHeader" runat="server" value="" onclick="MarkAll()" style="border:0px" />
                    </HeaderTemplate>
                    <ItemTemplate>
                        <input type="checkbox" id="cbxItem" runat="server" value='<%# Eval("PlayerID") %>' onclick="MarkOne()" />
                    </ItemTemplate>
                </asp:TemplateField>
                <asp:TemplateField HeaderText="STT">
                    <ItemTemplate><%# Container.DataItemIndex + 1 %></ItemTemplate>
                </asp:TemplateField>
                <asp:HyperLinkField  DataTextField="PlayerName" ItemStyle-Wrap="false" ItemStyle-HorizontalAlign="center" HeaderText="Tên cầu thủ" DataNavigateUrlFields="PlayerID" DataNavigateUrlFormatString="~/default.aspx?module=DetailPlayer&playerId={0}" />
                <asp:TemplateField HeaderText="Người tạo">
                    <ItemTemplate><%# Eval("CreatedBy") %></ItemTemplate>
                </asp:TemplateField>
                <asp:TemplateField HeaderText="Ngày tạo">
                    <ItemTemplate><%# FormHelper.FormatNormalDate(DateTime.Parse(Eval("CreatedDate").ToString())) %></ItemTemplate>
                </asp:TemplateField>
                <asp:TemplateField HeaderText="Trạng thái">
                    <ItemTemplate><%# Eval("Status") %></ItemTemplate>
                </asp:TemplateField> 
            </Columns>
        </asp:GridView>
        </td>
    </tr>
    <tr>
        <td colspan="2" align="left" class="links"><asp:Button ID="lnkAddBottom" runat="server" OnClick="lnkAdd_Click" Text="Thêm mới" />&nbsp;&nbsp;&nbsp;<asp:Button ID="lnkDeleteBottom" runat="server" OnClick="lnkDelete_Click" Text="Xóa" /></td>
    </tr>
</table>
<script language="javascript" type="text/javascript">
    var grid = document.getElementById('<%= this.grvPlayer.ClientID %>');
	
    function MarkAll()
    {
	    var isChecked = document.getElementById('<%= (this.grvPlayer.HeaderRow == null) ? "" : this.grvPlayer.HeaderRow.Cells[0].Controls[1].ClientID %>').checked;
	    for (i = 1; i < grid.rows.length; i++)
	    {
		    grid.rows[i].cells[0].children[0].checked = isChecked;
	    }
    }
    function MarkOne()
    {
	    var cbx = document.getElementById('<%= (this.grvPlayer.HeaderRow == null) ? "" : this.grvPlayer.HeaderRow.Cells[0].Controls[1].ClientID %>');
	    cbx.checked = false;
		
	    for (i = 1; i < grid.rows.length; i++)
	    {
		    if (!grid.rows[i].cells[0].children[0].checked) return;
	    }
	    cbx.checked = true;
    }
	
    function CheckSelect()
    {
	    for (i = 1; i < grid.rows.length; i++)
	    {
		    if (grid.rows[i].cells[0].children[0].checked) return true;
	    }
	    alert('Không có bản ghi nào được đánh dấu');
	    return false;
    }
</script>